#ifndef	VIEW3DINVENTORVIEWER_H_H_H_
#define VIEW3DINVENTORVIEWER_H_H_H_

#include "CKAll.h"
#include <QWidget>
#include "Selection.h"
//#include "Camera.h"
namespace Gui
{
class UnifiedSelection;
//class CameraRoot;
}

class ViewWindow;
class NavigationStyle;
class Document_Gui;
class view3DInventorViewer : public QFrame, public Gui::SelectionSingleton::ObserverType
{
public:
	view3DInventorViewer(QWidget* parent = NULL);
	~view3DInventorViewer(void);


	virtual void OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
		Gui::SelectionSingleton::MessageType Reason);

	enum DriverFlags 
	{
		eFamily			= 1,
		eDirectXVersion	= 2,
		eSoftware		= 4
	};

	void    Processkeyboard();

    BOOL     initializeRender(QWidget* w);
	void     destructRender();
	void     resizeRenderView(int width,int height);

	void setPopupMenuEnabled(const bool on);
	bool isPopupMenuEnabled(void)const;

	VxRect&  getViewRect();

	bool      process();

	void      processEvent(QEvent* e);

	void      setDocument(Document_Gui* pDocument);

	bool     checkPick(){return true;}

	void     processSelection(int smode);

	void     keyPressEvent(QKeyEvent* ke);
	void     keyReleaseEvent(QKeyEvent* e);

	void     mouseMoveEvent(QMouseEvent* e);
    void     mousePressEvent(QMouseEvent *);
	void     mouseReleaseEvent(QMouseEvent *);

protected:

	void paintEvent(QPaintEvent * e);
	QPaintEngine *paintEngine() const;


	bool event(QEvent* e);
	void timerEvent(QTimerEvent * e);

	void resizeEvent(QResizeEvent* e);






private:


	BOOL     _Load(const char* fn);
	BOOL	_InitPlugins(CKPluginManager& iPluginManager);
	int		_InitRenderEngines(CKPluginManager& iPluginManager);
	BOOL	_InitDriver();
	BOOL	_CheckDriver(VxDriverDesc* iDesc, int iFlags);
	BOOL	_CheckFullscreenDisplayMode(BOOL iDoBest);
	BOOL	_FinishLoad();


private:

	bool mPressFlag;	

	NavigationStyle*   navigation;
	Gui::UnifiedSelection*  selectionRoot;

	QTime watch;
	QBasicTimer ticker;

	CKLevel*            m_Level;

	//Gui::CameraRoot*            mCurrentCamera;

	CKContext*			m_CKContext;
	CKRenderContext*	m_RenderContext;
	CKRenderManager*	m_RenderManager;
	CKTimeManager*		m_TimeManager;
	CKInputManager*     m_InputManager;

	int					m_FullscreenWidth;		// fullscreen mode width
	int					m_FullscreenHeight;		// fullscreen mode height
	int					m_FullscreenBpp;		// fullscreen mode bpp
	BOOL				m_FullscreenEnabled;	// is fullscreen enable
	int					m_Driver;				// index of the current driver

	int					m_RasterizerFamily;		// see CKRST_RSTFAMILY
	int					m_RasterizerFlags;		// see CKRST_SPECIFICCAPS


};
#endif